<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回 PostgreSQL 服务器最新一条公告信息</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.pg-last-error.html">« pg_last_error</a></li>
      <li style="float: right;"><a href="function.pg-last-oid.html">pg_last_oid »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.pgsql.html">PostgreSQL 函数</a></li>
    <li>返回 PostgreSQL 服务器最新一条公告信息</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.pg-last-notice" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">pg_last_notice</h1> 
    <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pg_last_notice</span> &mdash; <span class="dc-title">
     返回 PostgreSQL 服务器最新一条公告信息
    </span></p>

   </div>
 
 <div class="refsect1 description" id="refsect1-function.pg-last-notice-description">
  <h3 class="title">说明</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>pg_last_notice</strong></span>(<span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection</code></span>): <span class="type">string</span></div>

    <p class="para rdfs-comment">
     <span class="function"><strong>pg_last_notice()</strong></span>
     返回由 <code class="parameter">connection</code>
     指定的 PostgreSQL 服务器最新的一条公告信息。PostgreSQL
     服务器在某些情况下会发送公告信息，例如在表里创建 <code class="literal">SERIAL</code> 列。
      </p>
  <p class="para">
     有了
     <span class="function"><strong>pg_last_notice()</strong></span>，只要检查公告是否和该事务有关，就可以避免提交无用的查询。
    </p>
   <p class="para">
   可以通过在 <var class="filename">php.ini</var> 中把
     <code class="literal">pgsql.ignore_notice</code> 置为 1 来使公告信息追踪成为可选项。
  </p>
  <p class="para">
   可以通过在 <var class="filename">php.ini</var> 中把
  <code class="literal">pgsql.log_notice</code> 置为 0 来使公告信息日志成为可选项。
   除非 <code class="literal">pgsql.ignore_notice</code> 为 0，否则公告信息不能被日志记录。
  </p>
   </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-last-notice-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">connection</code></dt>

     <dd>

      <p class="para">
       PostgreSQL database connection resource.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-last-notice-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   A <span class="type">string</span> containing the last notice on the 
   given <code class="parameter">connection</code>, or <strong><code>false</code></strong> on error.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-last-notice-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.3.0</td>
       <td>
          本函数在 PHP 4.3.0 中完全实现。低于 PHP 4.3.0 的版本中都忽略了数据库连接参数。
       </td>
      </tr>

      <tr>
       <td>4.3.0</td>
       <td>
        The <code class="literal">pgsql.ignore_notice</code> and 
        <code class="literal">pgsql.log_notice</code> <var class="filename">php.ini</var> directives were added.
       </td>
      </tr>

      <tr>
       <td>4.0.6</td>
       <td>
         PHP 4.0.6
  本身在公告信息处理上有问题。即使不使用
  <span class="function"><strong>pg_last_notice()</strong></span> 函数，也不推荐在 PHP 4.0.6
  中使用 PostgreSQL 模块。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.pg-last-notice-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1916">
    <p><strong>示例 #1 <span class="function"><strong>pg_last_notice()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;$pgsql_conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=mark&nbsp;host=localhost"</span><span style="color: #007700">);<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$res&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"CREATE&nbsp;TABLE&nbsp;test&nbsp;(id&nbsp;SERIAL)"</span><span style="color: #007700">);<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$notice&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_last_notice</span><span style="color: #007700">(</span><span style="color: #0000BB">$pgsql_conn</span><span style="color: #007700">);<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$notice</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
CREATE TABLE will create implicit sequence &quot;test_id_seq&quot; for &quot;serial&quot; column &quot;test.id&quot;
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.pg-last-notice-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.pg-query.html" class="function" rel="rdfs-seeAlso">pg_query()</a> - 执行查询</span></li>
    <li class="member"><span class="function"><a href="function.pg-last-error.html" class="function" rel="rdfs-seeAlso">pg_last_error()</a> - 得到某连接的最后一条错误信息</span></li>
   </ul>
  </p>
 </div>

  </div></div></div></body></html>